package com.jwsoft.manager.core.gateway.controller;

import cn.hutool.core.convert.Convert;
import com.bifang.assistant.common.constants.Validators;
import com.bifang.assistant.common.vo.BasePageVO;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduSchoolConfig.*;
import com.jwsoft.manager.core.integration.EduSchoolConfigIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 所属学校配置表网关
 *
 * @author hhj
 * @since 2022-12-21
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "所属学校招生计划表", description = "所属学校招生计划表")
public class EduSchoolConfigController {

    @Autowired
    public EduSchoolConfigIntegration eduSchoolConfigIntegration;

    @Operation(summary = "幼儿园学校招生计划管理分页查询",description = "幼儿园学校招生计划管理分页查询")
    @PostMapping(value = "/eduSchoolConfig0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduSchoolConfigVO>> getList(@RequestBody @Validated EduSchoolConfigQueryVO vo) {
        return AppResponse.successData(eduSchoolConfigIntegration.getList(vo));
    }

    @Operation(summary = "所属学校配置表根据主键查询详情",description = "所属学校配置表根据主键查询详情")
    @PostMapping(value = "/eduSchoolConfig0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolConfigVO> getById(@RequestBody @Validated EduSchoolConfigKeyVO vo) {
        return AppResponse.successData(eduSchoolConfigIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "幼儿园学校招生计划管理新增",description = "幼儿园学校招生计划管理新增")
    @PostMapping(value = "/eduSchoolConfig0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolConfigVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduSchoolConfigVO vo) {
        return AppResponse.successData(eduSchoolConfigIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "幼儿园学校招生计划管理修改",description = "幼儿园学校招生计划管理修改")
    @PostMapping(value = "/eduSchoolConfig0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolConfigVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduSchoolConfigVO vo) {
        return AppResponse.successData(eduSchoolConfigIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "所属学校配置表删除",description = "所属学校配置表删除")
    @PostMapping(value = "/eduSchoolConfig0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduSchoolConfigKeyVO vo) {
        eduSchoolConfigIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }


    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "复制上年学校配置",description = "复制上年学校配置")
    @PostMapping(value = "/eduSchoolConfig0009", produces = "application/json;charset=UTF-8")
    public AppResponse copyLastYearConfig(@RequestBody @Validated SchoolConfigSaveVO req) {

        SchoolConfigSaveVO vo = Convert.convert(SchoolConfigSaveVO.class, req);
        eduSchoolConfigIntegration.copyLastYearConfig(vo);
        return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "幼儿园停止招生",description = "幼儿园停止招生")
    @PostMapping(value = "/eduSchoolConfig0011", produces = "application/json;charset=UTF-8")
    public void stopNurseryRecruit(@RequestBody @Validated EduSchoolConfigKeyVO vo) {
        eduSchoolConfigIntegration.stopNurseryRecruit(vo);
    }


    @Operation(summary = "获取招生开始时间",description = "获取招生开始时间")
    @PostMapping(value = "/eduSchoolConfig0012", produces = "application/json;charset=UTF-8")
    public AppResponse getEnrollStartTime(@RequestBody @Validated BasePageVO vo) {

        return AppResponse.successData(eduSchoolConfigIntegration.getEnrollStartTime(vo));
    }

    @Operation(summary = "获取学段年龄时间",description = "获取招生学段年龄时间")
    @PostMapping(value = "/eduSchoolConfig0013", produces = "application/json;charset=UTF-8")
    public AppResponse getAgeTime(@RequestBody @Validated SchoolConfigQueryVO vo) {

        return AppResponse.successData(eduSchoolConfigIntegration.getAgeTime(vo));
    }

    @Operation(summary = "义务教育学校配置表查询",description = "义务教育学校配置表查询")
    @PostMapping(value = "/eduSchoolConfig0014", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<SchoolConfigVO>> getYwSchoolConfigInfo(@RequestBody @Validated SchoolConfigQueryVO vo) {
        return AppResponse.successData(eduSchoolConfigIntegration.getYwSchoolConfigInfo(vo));
    }


    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "义务教育学校配置表新增",description = "义务教育学校配置表新增")
    @PostMapping(value = "/eduSchoolConfig0015", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolConfigVO> saveYwSchoolConfigInfo(@RequestBody @Validated SchoolConfigSaveVO vo) {
      eduSchoolConfigIntegration.saveYwSchoolConfigInfo(vo);
      return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "义务教育学校配置表更新",description = "义务教育学校配置表更新")
    @PostMapping(value = "/eduSchoolConfig0016", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolConfigVO> updateYwSchoolConfigInfo(@RequestBody @Validated SchoolConfigSaveVO vo) {
        eduSchoolConfigIntegration.updateYwSchoolConfigInfo(vo);
        return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "义务教育招生计划提交审核",description = "义务教育招生计划提交审核")
    @PostMapping(value = "/eduSchoolConfig0018", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolConfigVO> tjAudit(@RequestBody @Validated SchoolConfigQueryVO vo) {
        eduSchoolConfigIntegration.tjAudit(vo);
        return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "义务教育学校配置审核",description = "义务教育学校配置审核")
    @PostMapping(value = "/eduSchoolConfig0019", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolConfigVO> auditYwSchoolConfig(@RequestBody @Validated SchoolConfigSaveVO vo) {
        eduSchoolConfigIntegration.auditYwSchoolConfig(vo);
        return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "义务教育学校停止招生",description = "义务教育学校停止招生")
    @PostMapping(value = "/eduSchoolConfig0020", produces = "application/json;charset=UTF-8")
    public AppResponse stopYwSchoolRecruit(@RequestBody @Validated SchoolConfigSaveVO vo) {
        eduSchoolConfigIntegration.stopYwSchoolRecruit(vo);
        return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "义务教育招生计划退回到待审核",description = "义务教育招生计划退回到待审核")
    @PostMapping(value = "/eduSchoolConfig0021", produces = "application/json;charset=UTF-8")
    public AppResponse rejectSchoolConfig(@RequestBody @Validated SchoolConfigSaveVO vo) {
        eduSchoolConfigIntegration.rejectSchoolConfig(vo);
        return AppResponse.success();
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "幼儿园恢复招生",description = "幼儿园恢复招生")
    @PostMapping(value = "/eduSchoolConfig0022", produces = "application/json;charset=UTF-8")
    public void recoverNurseryRecruit(@RequestBody @Validated EduSchoolConfigRecruitVO vo) {
        eduSchoolConfigIntegration.recoverNurseryRecruit(vo);
    }


}
